package com.amos.cmp_android.ui;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.TextView;

import com.amos.cmp_android.R;
import com.amos.cmp_android.constant.URLConstant;
import com.facebook.drawee.backends.pipeline.Fresco;
import com.facebook.drawee.view.DraweeView;

/**
 * Created by Amos on 2016/5/4.
 */
public class ShowTeacherActivity extends AppCompatActivity {

    private DraweeView draweeView;
    private TextView name;
    private TextView xi;
    private TextView sex;
    private TextView intro;
    private Toolbar toolbar;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Fresco.initialize(ShowTeacherActivity.this);
        setContentView(R.layout.activity_show_teacher);

        name = (TextView) findViewById(R.id.teacher_name);
        sex = (TextView) findViewById(R.id.teacher_sex);
        xi = (TextView) findViewById(R.id.teacher_xi);
        intro = (TextView) findViewById(R.id.teacher_intro);
        draweeView = (DraweeView) findViewById(R.id.teacher_img);
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("教师详情");
        setSupportActionBar(toolbar);
        Intent intent = getIntent();

        name.setText(intent.getStringExtra("name"));
        sex.setText(intent.getStringExtra("sex"));
        xi.setText(intent.getStringExtra("xi"));
        intro.setText(intent.getStringExtra("intro"));
        draweeView.setController(Fresco.newDraweeControllerBuilder().
                setUri(Uri.parse(URLConstant.HOST + intent.getStringExtra("picUrl"))).
                setAutoPlayAnimations(true).build());

        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

}
